<template>
	<view>
		<button open-type="getUserInfo" @getuserinfo="wxLogin">点我登录</button>
	</view>
</template>

<script>
	export default {
		methods: {
			// 用户登录
			wxLogin(even) {
				console.log(even.detail)
				let {
					encryptedData,
					rawData,
					iv,
					signature,
				} = even.detail
				wx.login({
					success: async loginRes => {
						const {code} = loginRes
						let data = await this.$request({
							url: '/api/public/v1/users/wxlogin',
							method: 'post',
							data: {
								encryptedData,
								rawData,
								iv,
								signature,
								code,
							}
						})
						console.log(data)
					}
				})
			}
		}
	}
</script>

<style>
</style>
